package com.panghu.controller;


import com.panghu.entity.ApiResult;
import com.panghu.entity.FillQuestion;
import com.panghu.service.FillQuestionService;
import com.panghu.utils.ApiResultHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 填空题题库 前端控制器
 * </p>
 *
 * @author huahua
 * @since 2022-03-19
 */
@RestController
public class FillQuestionController {

    @Autowired
    FillQuestionService fillQuestionService;

    @PostMapping("/fillQuestion")
    public ApiResult add(@RequestBody FillQuestion fillQuestion) {
        //增加判断题
        boolean save = fillQuestionService.save(fillQuestion);
        if(save){
            return ApiResultHandler.buildApiResult(200,"增加成功",save);
        }else {
            return ApiResultHandler.buildApiResult(400,"增加失败",save);
        }
    }

    @GetMapping("/fillQuestionId")
    public ApiResult findOnlyQuestionId() {
        //按id查询判断题
        return ApiResultHandler.success(fillQuestionService.findOnlyQuestionId());
    }
}

